<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>个人注册</title>
    <style>
        body {
            font-family: PingFang SC, Helvetica Neue, Helvetica, Arial, Hiragino Sans GB, Microsoft Yahei, \5FAE软雅黑, STHeiti, \534E文细黑, sans-serif;
            color: #666;
            font-size: 12px;
            margin: 0;
            background-size: cover;
            text-align: center;
        }

        * {
            padding: 0;
            margin: 0;
        }

        .card {
            width: 450px;
            height: 567px;
            margin: 100px auto;
            border-radius: 10px;
            overflow: hidden;
            border: 1px solid #666666;
        }

        li {
            list-style-type: none;
        }

        h2 {
            height: 61px;
            color: #666666;
            border-bottom: 1px solid #666666;
            font-size: 20px;
            line-height: 61px;
        }

        .card_b > div > input {
            display: block;
            margin: 0 auto 15px;
            width: 370px;
            height: 50px;
            border-radius: 7px;
            padding-left: 20px;
            font-size: 15px;
            border: 1px solid #666666;
        }


        .card_b {
            padding-top: 39px;
        }

        .button {
            display: block;
            width: 372px;
            height: 50px;
            margin: 30px auto;
            border: 0;
            background-color: rgb(86, 126, 225);
            border-radius: 3px;
            color: white;
            font-size: 20px;
        }

        a {
            color: blue;
            text-decoration: none;
        }

        hr {
            width: 372px;
            margin: 50px auto;
        }


    </style>
</head>
<body>
<div id="app">
    <div class="card">
        <h2>注册YXMall账号</h2>
        <div class="card_b">
            <div>
                <input type="text" v-model="user.username" placeholder="用户名">

                <input type="password" v-model="user.password" placeholder="密码">

            </div>

            <input type="checkbox" v-model="user.accept"> 我已阅读并同意遵守<a href="">法律声明</a>和<a href="">隐私条款</a>

            <input class="button" type="button" @click="reg()" value="注册">
            <hr>
            <span>如果您已拥有 YXMall 账号，则可在此<a href="/login.html">登陆</a> </span>
        </div>

    </div>


</div>
<script src="https://cdn.bootcdn.net/ajax/libs/axios/0.21.1/axios.min.js"></script>
<script src=" https://cdn.staticfile.org/vue/2.2.2/vue.min.js"></script>
<!-- import JavaScript -->
<script src="https://cdn.staticfile.org/element-ui/2.15.9/index.min.js"></script>
<script>
    let v = new Vue({
        el: "#app",
        data: function () {
            return {
                user: {
                    username: "",
                    password: "",
                    accept:false
                }
            }
        },
        methods: {
            reg() {
                if (v.user.username!=''&&v.user.password!=''&&v.user.accept == true){
                    axios.post("/reg", v.user).then(function (response) {
                        if (response.data == 1) {
                            alert("注册成功")
                            location.href = '/login.html'
                        } else{
                            alert("用户名已存在，请重新输入!")
                        }
                    })
                }else {
                    confirm("请完整填写相关信息并同意后注册!")
                }
            }
        }
    })
</script>
</body>
</html>